'use strict';

module.exports = app => {
  const { INTEGER, TEXT, BOOLEAN, DATE } = app.Sequelize;

  const ThemeComment = app.model.define('theme_comment', {
    id: { type: INTEGER, primaryKey: true, autoIncrement: true },
    theme_id: INTEGER,
    user_id: INTEGER,
    content: TEXT('long'),
    oline: BOOLEAN,
    hot: BOOLEAN,
    create_time: DATE,
    update_time: DATE,
    delete_time: DATE,
  }, {
    defaultScope: {
      attributes: {
        exclude: [ 'delete_time', 'update_time' ],
      },
    },
    timestamps: true,
    paranoid: true,
    createdAt: 'create_time',
    updatedAt: 'update_time',
    deletedAt: 'delete_time'
  });

  ThemeComment.associate = function() {
    app.model.ThemeComment.belongsTo(app.model.User, {
      as: 'user',
      foreignKey: 'user_id',
      targetKey: 'id'
    });

    
  }

  return ThemeComment;
};
